Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test-process-kill-null.js for Windows #14099

Closed

Conversation

starkwang
Copy link
Contributor

The test-process-kill-null.js failed in Windows because cat command is invalid for Windows cmd.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 6, 2017
@richardlau
Copy link
Member

The test-process-kill-null.js failed in Windows because cat command is invalid for Windows cmd.

It's included in Git bash. From BUILDING.md:

  • Basic Unix tools required for some tests, Git for Windows includes Git Bash and tools which can be included in the global PATH.

@starkwang starkwang closed this Jul 6, 2017
@refack refack reopened this Jul 7, 2017
@refack
Copy link
Contributor

refack commented Jul 7, 2017

I want this.
The MSYS cat is a ported utility and it's not as robust on windows as it is on *nix.
If we could remove the git-for-windows dependancy, all the better.

@@ -24,24 +24,24 @@ require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

const cat = spawn('cat');
const child = process.platform === 'win32' ? spawn('cmd.exe') : spawn('cat');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recommended test is common.isWindows (assign const common on L23)


cat.on('exit', function() {
child.on('exit', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add common.mustCall

@@ -24,24 +24,24 @@ require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

const cat = spawn('cat');
const child = process.platform === 'win32' ? spawn('cmd.exe') : spawn('cat');
let called;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

}, Error);
});

cat.stdout.on('data', function() {
child.stdout.on('data', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add common.mustCall

}, Error);
});

cat.stdout.on('data', function() {
child.stdout.on('data', function() {
called = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

});

// EPIPE when null sig fails
cat.stdin.write('test');
child.stdin.write('test');

process.on('exit', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

@refack refack added process Issues and PRs related to the process subsystem. windows Issues and PRs related to the Windows platform. labels Jul 7, 2017
@starkwang
Copy link
Contributor Author

Pushed commit to address comments.

@refack
Copy link
Contributor

refack commented Jul 7, 2017

refack pushed a commit to refack/node that referenced this pull request Jul 8, 2017
PR-URL: nodejs#14099
Reviewed-By: Refael Ackermann <refack@gmail.com>
@refack
Copy link
Contributor

refack commented Jul 8, 2017

landed in 44483b6

@refack refack closed this Jul 8, 2017
@refack
Copy link
Contributor

refack commented Jul 8, 2017

@refack
Copy link
Contributor

refack commented Jul 8, 2017

@starkwang might will need a followup PR to fix this flakiness:

not ok 235 parallel/test-process-kill-null
  ---
  duration_ms: 0.255
  severity: fail
  stack: |-
    internal/process.js:190
          throw errnoException(err, 'kill');
          ^
    
    Error: kill ESRCH
        at exports._errnoException (util.js:1023:11)
        at process.kill (internal/process.js:190:13)
        at Socket.<anonymous> (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vs2015\label\win2012r2\test\parallel\test-process-kill-null.js:38:11)
        at Socket.<anonymous> (c:\workspace\node-test-binary-windows\RUN_SUBSET\3\VS_VERSION\vs2015\label\win2012r2\test\common\index.js:518:15)
        at emitOne (events.js:115:13)
        at Socket.emit (events.js:210:7)
        at addChunk (_stream_readable.js:252:12)
        at readableAddChunk (_stream_readable.js:239:11)
        at Socket.Readable.push (_stream_readable.js:197:10)
        at Pipe.onread (net.js:589:20)
  ...

https://ci.nodejs.org/job/node-test-binary-windows/9711/RUN_SUBSET=3,VS_VERSION=vs2015,label=win2012r2/

Running another windows CI: https://ci.nodejs.org/job/node-test-commit-windows-fanned/10278/

@refack refack mentioned this pull request Jul 9, 2017
3 tasks
refack added a commit to refack/node that referenced this pull request Jul 9, 2017
This reverts commit 44483b6.

PR-URL: nodejs#14142
Fixes: nodejs#14141
Refs: nodejs#14099
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@refack refack reopened this Jul 9, 2017
@refack
Copy link
Contributor

refack commented Jul 9, 2017

@nodejs/platform-windows could the kill ESRCH ("No such process") actually be a bug?
micro context:

child.stdout.on('data', common.mustCall(function() {
  process.kill(child.pid, 'SIGKILL');
}

@richardlau
Copy link
Member

It probably means the child has exited before the kill was attempted.

https://nodejs.org/dist/latest-v8.x/docs/api/child_process.html#child_process_child_kill_signal

The ChildProcess object may emit an 'error' event if the signal cannot be delivered.

@refack
Copy link
Contributor

refack commented Jul 9, 2017

It probably means the child has exited before the kill was attempted.

https://nodejs.org/dist/latest-v8.x/docs/api/child_process.html#child_process_child_kill_signal

The ChildProcess object may emit an 'error' event if the signal cannot be delivered.

It's more a case of https://nodejs.org/dist/latest-v8.x/docs/api/process.html#process_process_kill_pid_signal

This method will throw an error if the target pid does not exist.
...
Windows platforms will throw an error if the pid is used to kill a process group.

But presumably in this case we attempt to kill only if we get something from stdout.
I'll try to repro locally. I smell something fishy 👃

@richardlau
Copy link
Member

The child process can exit between Node.js reading stdout and calling the on 'data' callback.

@gibfahn
Copy link
Member

gibfahn commented Jul 12, 2017

@refack can you open a new PR? Now this has been reverted I don't think we should keep using it, it's likely to confuse things like branch-diff (and collaborators!).

IDK if there's a standard way to do this, but don't land a PR twice seems like a reasonable rule.

@gibfahn gibfahn closed this Jul 12, 2017
@refack
Copy link
Contributor

refack commented Jul 12, 2017

@refack can you open a new PR? Now this has been reverted I don't think we should keep using it, it's likely to confuse things like branch-diff (and collaborators!).

IDK if there's a standard way to do this, but don't land a PR twice seems like a reasonable rule.

I consulted with @addaleax and @Trott and this seems like the "standard" way 🤷‍♂️

@gibfahn
Copy link
Member

gibfahn commented Jul 12, 2017

I consulted with @addaleax and @Trott and this seems like the "standard" way 🤷‍♂️

Happy to be wrong if others disagree.

@Trott
Copy link
Member

Trott commented Jul 12, 2017

I consulted with @addaleax and @Trott and this seems like the "standard" way 🤷‍♂️

I'm not 100% sure that re-landing from the same PR is the standard way. But if @addaleax says it's OK, that's good enough for me.

@addaleax
Copy link
Member

I wouldn’t know that there’s a standard way to handle this either. Opening a new PR is certainly easier for everyone and will make sure the new commit won’t get overlooked, but reverts are probably rare enough that handling them manually is feasible.

@refack
Copy link
Contributor

refack commented Jul 12, 2017

@starkwang Would you like to open a new PR for this?

@starkwang
Copy link
Contributor Author

Yes, I'd like to do it. I'm trying to reproduce the flakiness locally.

@refack
Copy link
Contributor

refack commented Jul 12, 2017

@starkwang you could try spawn('type con', { shell: true }) that will start cmd.exe with the right arguments to run type con which is sort of the equivalent to cat with no args

@refack
Copy link
Contributor

refack commented Jul 12, 2017

P.S. @starkwang if you want your full name in the logs you could follow https://help.github.com/articles/setting-your-username-in-git/

@gibfahn
Copy link
Member

gibfahn commented Jul 13, 2017

So at the moment your Git author name and email address are set to:

starkwang <381152119@qq.com>

People usually choose to use their full names for commits. To set your name globally you can do:

git config --global user.name "Weijia Wang"
git config --global user.email "381152119@qq.com"

To change the author for a single commit you can do:

git commit --amend --author="Weijia Wang <381152119@qq.com>"
git push --force-with-lease

It's entirely optional.

@starkwang
Copy link
Contributor Author

@gibfahn Thanks for your suggestion! :D
I've changed the user information in Git.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process Issues and PRs related to the process subsystem. test Issues and PRs related to the tests. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants